﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ClienteWinMGI.Presentacion;

namespace ClienteWinMGI
{
    public partial class principal : Form
    {
        Control _actual = null;

        public principal()
        {
            InitializeComponent();
            StartMarquee();
            _actual = null;
        }

        private void clientesYSolucionesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Control panelGral = this.Controls["panelGeneral"];
            if ( _actual == null ){
                _actual = new GestionControl();
                panelGral.Controls.Add(_actual);
            }
            else{
                _actual.Dispose();
                panelGral.Controls.Remove(_actual);
                _actual = new GestionControl();
                panelGral.Controls.Add(_actual);
            }
            ((TabControl)_actual.Controls["tabsGestion"]).SelectedTab = ((TabControl)_actual.Controls["tabsGestion"]).TabPages[0];
            _actual.BringToFront();
            panelGral.Refresh();
        }

        private void incidentesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Control panelGral = this.Controls["panelGeneral"];
            if (_actual == null)
            {
                _actual = new GestionControl();
                panelGral.Controls.Add(_actual);
            }
            else
            {
                _actual.Dispose();
                panelGral.Controls.Remove(_actual);
                _actual = new GestionControl();
                panelGral.Controls.Add(_actual);
            }
            ((TabControl)_actual.Controls["tabsGestion"]).SelectedTab = ((TabControl)_actual.Controls["tabsGestion"]).TabPages[1];
            _actual.BringToFront();
            panelGral.Refresh();
        }

        private void workPackagesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Control panelGral = this.Controls["panelGeneral"];
            if (_actual == null)
            {
                _actual = new GestionControl();
                panelGral.Controls.Add(_actual);
            }
            else
            {
                _actual.Dispose();
                panelGral.Controls.Remove(_actual);
                _actual = new GestionControl();
                panelGral.Controls.Add(_actual);
            }
            ((TabControl)_actual.Controls["tabsGestion"]).SelectedTab = ((TabControl)_actual.Controls["tabsGestion"]).TabPages[2];
            _actual.BringToFront();
            panelGral.Refresh();
        }

        private void hitosToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Control panelGral = this.Controls["panelGeneral"];
            if (_actual == null)
            {
                _actual = new GestionControl();
                panelGral.Controls.Add(_actual);
            }
            else
            {
                _actual.Dispose();
                panelGral.Controls.Remove(_actual);
                _actual = new GestionControl();
                panelGral.Controls.Add(_actual);
            }
            ((TabControl)_actual.Controls["tabsGestion"]).SelectedTab = ((TabControl)_actual.Controls["tabsGestion"]).TabPages[3];
            _actual.BringToFront();
            panelGral.Refresh();
        }

        private void tareasToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Control panelGral = this.Controls["panelGeneral"];
            if (_actual == null)
            {
                _actual = new GestionControl();
                panelGral.Controls.Add(_actual);
            }
            else
            {
                _actual.Dispose();
                panelGral.Controls.Remove(_actual);
                _actual = new GestionControl();
                panelGral.Controls.Add(_actual);
            }
            ((TabControl)_actual.Controls["tabsGestion"]).SelectedTab = ((TabControl)_actual.Controls["tabsGestion"]).TabPages[4];
            _actual.BringToFront();
            panelGral.Refresh();
        }

        //Controles del Marquee
        private void StartMarquee()
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder(//marquee.Text
            "Incidentes: 45"
            + "                                                                         "
            + "                                                                         "
            + "Tareas: 133"
            + "                                                                         "
            + "                                                                         "
            + "Work Packages: 23"
            + "                                                                         "
            + "                                                                         "
            + "Hitos: 2"
            + "                                                                         "
            + "                                                                         ");
            marquee.Text = sb.ToString();
        }
      
        private void MoveMarquee()
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder(marquee.Text);
            char ch = sb[0];
            sb.Remove(0, 1);
            sb.Insert(sb.Length, ch);
            marquee.Text = sb.ToString();
            marquee.Refresh();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            MoveMarquee();
        }

        private void asignarResponsableATareaToolStripMenuItem_Click(object sender, EventArgs e)
        {
            new AsignarResponsableATarea().Show();
        }

        private void reporteDeIncidentesCerradosEnUnPeriodoToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ReporteIncidentesCerradosPeriodo ricp = new ReporteIncidentesCerradosPeriodo();
            ricp.ShowDialog();
        }
    }
}
